// Roles.cpp: implementation of the CRoles class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "activcard.h"
#include "Roles.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CRoles::CRoles(CStorage& storage)
: m_storage(storage)
{
	m_storage.GetRoles( m_mapRoles );
}

CRoles::~CRoles()
{

}

void CRoles::AddRole(const CString &strRoleName, const CStringItemsArray &arrAdmittanceGatewaysNames)
{
	m_storage.AddRole( strRoleName, arrAdmittanceGatewaysNames );

	m_mapRoles[strRoleName] = arrAdmittanceGatewaysNames;
}

void CRoles::UpdateRole(const CString &strOriginalRoleName, const CString &strNewRoleName, const CStringItemsArray &arrAdmittanceGatewaysNames)
{
	m_storage.UpdateRole( strOriginalRoleName, strNewRoleName, arrAdmittanceGatewaysNames );

ASSERT(TRUE==
	m_mapRoles.RemoveKey( strOriginalRoleName )	);
	m_mapRoles[strNewRoleName] = arrAdmittanceGatewaysNames;
}

void CRoles::DeleteRole(const CString &strRoleName)
{
	m_storage.DeleteRole( strRoleName );
	
ASSERT(TRUE==
	m_mapRoles.RemoveKey( strRoleName )	);
}
